<template>
  <div class="cd">
  <div class="zd">
  <div class="dl">
  </div>
    <div class="ddl">
  <el-form label-width="80px">
    <el-form-item label="用户名">
      <el-input v-model="username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="password" show-password=true></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="login">登录</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
  </div>
  </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "Login",
  data(){
    return{
        username:'',
        password:'',
      user:''
    }
  },
  methods:{
    login(){
      axios.post("/student/login?username="+this.username+"&password="+this.password).then(resp=>{
        if(resp.data.flag){
          this.$notify({
            title: '成功',
            message: '登录成功',
            type: 'success'
          });
          console.log(resp.data.data)
          this.user=resp.data.data;
          window.sessionStorage.setItem("user",JSON.stringify(resp.data.data))
          if(this.user.utype==1){
            this.$router.push("/home");
          }else if(this.user.utype==3){
            this.$router.push("/shome")
          }
        }else {
          this.$message.error("登录失败");
        }
      })
    }
  }
}
</script>

<style scoped>
.cd{
  width:1430px;
  height:608px;
}
.zd{
  width: 80%;
  height: 550px;
  padding-left: 100px;
  margin: 0 auto;
  margin-top: 100px;
}
  .dl{
    height: 500px;
    float: left;
    width: 55%;
    background-image: url("../assets/ppp.webp");
    background-repeat:no-repeat;
    background-size: 100%;
    margin-top: 70px;
  }
  .ddl{
    float: right;
    padding-top: 200px;
    width: 25%;
    float: right;
    padding-right:200px;
  }
</style>